//
//  ShowEmptyView.m
//  CarsFiles_QYB
//
//  Created by 程虎 on 2017/4/20.
//  Copyright © 2017年 程虎. All rights reserved.
//

#import "ShowEmptyView.h"

@interface ShowEmptyView()
@property (nonatomic, strong) UIView *bkView;
@property (nonatomic, strong) UILabel *lab;
@end

@implementation ShowEmptyView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self set_UI];
    }
    return self;
}

- (instancetype)initWithView:(UIView *)views
{
    self = [super init];
    if (self) {
//        [views addSubview:self];
//        self.sd_layout.leftSpaceToView(views, 0).centerXEqualToView(views).rightSpaceToView(views, 0).centerYEqualToView(views).heightIs(100);
        
        [self set_UI];
    }
    return self;
}

- (void)set_UI
{
    self.bkView = [UIView new];
    UIView *views = [UIView new];
    views.backgroundColor = [UIColor clearColor];
    UIImage *pic = [UIImage imageNamed:@"emity_icon"];
    CGFloat scale = pic.size.height / pic.size.width;
    
    UIImageView *img = [UIImageView new];
    img.image = pic;
    
    self.lab = [UILabel new];
    self.lab.textColor = [UIColor lightGrayColor];
    self.lab.textAlignment = NSTextAlignmentCenter;
    self.lab.font = LRFont(17);
    self.lab.text = @"暂无数据";
    
    [self addSubview:views];
    [views sd_addSubviews:@[img,self.lab]];
    
    views.sd_layout.centerXEqualToView(self).centerYEqualToView(self).widthRatioToView(self, 1);
    
    img.sd_layout
    .centerXEqualToView(views)
    .topSpaceToView(views, 0)
    .widthIs(100 * AutoScaleX)
    .autoHeightRatio(scale);
    
    self.lab.sd_layout
    .centerXEqualToView(img)
    .topSpaceToView(img, 5)
    .widthRatioToView(views, 1)
    .heightIs(30);
    [views setupAutoHeightWithBottomView:self.lab bottomMargin:0];
}

-(void)setNoticeStr:(NSString *)noticeStr
{
    _noticeStr = noticeStr;
    self.lab.text = noticeStr;
}


@end
